A computer apparatus can provide one or more hardware interfaces for hardware devices to access. An operating system of the computer apparatus allocates device numbers to the hardware devices and identifies a corresponding hardware device based on the device number.
However, the operating system employs a dynamic allocation plan based on preemption principles for allocating the device numbers. Naming the hardware device with the first currently available device number can cause the device number of the hardware device to change before and after the reallocation. For example, in a case where a hardware interface used by the hardware device is changed, in other words, in a case where the hardware device is unplugged from one hardware interface of the computer apparatus and accessed to another hardware interface, based on the above dynamic allocation plan, the operating system may allocate different device numbers for the hardware device before and after the re-access.
Alternatively, even in a case where the hardware device doesn't change the used hardware interface, due to changes in the order in which the hardware device is loaded, the order in which the hardware device controller reports the hardware device to the operating system kernel, the scanning order of a peripheral component interconnect (PCI) bus, the order in which the hardware device controller is hot-swapped, or the order in which the hardware device is hot-swapped, etc., the device number allocated by the operating system for the hardware device may change, and thus, the device number of the hardware device may change before and after the reallocation.
In a case where the device number allocated by the operating system for the hardware device changes before and after the reallocation, the operating system cannot identify the hardware device using a fixed device number, making it extremely inconvenient to execute certain applications. For example, to execute a script program in the operating system, a device number of a hardware device is used in the script program. After the hardware device accesses to another different hardware interface, the device number in the script program needs to be manually modified to be the different allocated device number.
The disclosed method and computer apparatus are directed to solve one or more problems set forth above and other problems.